import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int l= sc.nextInt();
        int[] arr=new int[l+1];
        for(int i=0;i<=l;i++)
        {
            arr[i]=1;
        }
        int station_count= sc.nextInt();
        for(int j=0;j<station_count;j++)
        {
            int start=sc.nextInt();
            int end=sc.nextInt();
            for(int k=start;k<=end;k++)
            {
                if(arr[k]==1)
                    arr[k]=0;
            }
        }
        System.out.println(Arrays.stream(arr).sum());
    }
}
